<html><head>
<meta http-equiv=Content-Type Content="text-html; charset=utf-8">
<meta http-equiv=MSThemeCompatible Content=Yes>
<meta http-equiv=Author Content=mozers>
<hta:application
id=HTML_TB
applicationName=HTML_Toolbar
maximizeButton=no
border=dialog
innerBorder=yes
borderStyle=raised
scroll=no
selection=no
contextMenu=no
caption=no
showInTaskBar=no
singleinstance=yes
version=1.3
>
<title>html Toolbar</title>
<style type="text/css">
	body, table {font-family:MS Shell Dlg; font-size:8pt; background-color:threedface; cursor:default; margin:0px;}
	button {font-family:MS Shell Dlg; font-size:8pt; font-weight:bold; color:#0000CC;}
</style>
<script language="JavaScript">
try {
	var SciTE=new ActiveXObject("SciTE.Helper");
} catch(e) {
	alert("Please install SciTE Helper before!");
	self.close();
}

function ReadIniFile (filename) {
	var fso = new ActiveXObject("Scripting.FileSystemObject");
	if (fso.FileExists(filename)) {
		if (fso.GetFile(filename).Size > 0) {
			var file = fso.OpenTextFile(filename, 1);
			var text = file.ReadAll();
			file.Close();
			return text;
		}
	}
}
var filename = SciTE.Props ("SciteUserHome") + "\\HTML_toolbar.ini";
var buttons = ReadIniFile (filename);
var Arr_BTN = [];

if (buttons){
	var Arr_tmp=buttons.split("\r\n");
	for (i=0;i<Arr_tmp.length;i++){
		Arr_BTN[i] = /(.*?)=(.*)/.exec(Arr_tmp[i]);
	}
}

var btn_html = "";
for (i=0;i<Arr_BTN.length;i++){
	if (Arr_BTN[i]) {
		btn_html += "<button onClick=\"AddTag(" + i + ")\">" + Arr_BTN[i][1] + "</button>&nbsp;";
	}else{
		btn_html += "<font size='3' disabled>|</font>&nbsp;";
	}
}

function AddTag(i){
	var pattern = Arr_BTN[i][2].replace(/\|/, "¦");

	var text = SciTE.GetSelText;
	text = pattern.replace(/%SEL%/g,text);

	var clp = window.clipboardData.getData('Text');
	text = text.replace(/%CLP%/g,clp);

	var cursor = text.indexOf("¦");
	if (cursor!=-1) {
		text = text.replace(/¦/,"");
	} else {
		cursor = text.length;
	}
	var pos = parseInt(SciTE.LUA ("editor.SelectionStart")) + cursor;
	SciTE.ReplaceSel(text);
	SciTE.LUA ("editor:GotoPos("+pos+")");
	SciTE.Focus();
}
</script>
</head><body onLoad="SciTE.onTop(document.title, true);">
<table id="TB"><tr>
<td style="white-space:nowrap;"><span id="BTN"></span></td>
<td style="white-space:nowrap;" onClick="window.location.reload();" title="левая кнопка мыши - Обновить
правая - Перетащить">&nbsp;&nbsp;<button onClick="SciTE.Send('open:' + filename);" style="font: normal 10pt Marlett; color:green;" title="Настройка">s</button>&nbsp;<button onClick="self.close();" style="font: normal 10pt Marlett; color:red;" title="Закрыть">r</button></td>
</tr></table>
</body>
<script language="JavaScript">
BTN.innerHTML = btn_html;
window.resizeTo(TB.offsetWidth+4, 31);
window.moveTo(SciTE.Left+60, SciTE.Top+90);
TB.focus();

function cursor(c){
	for (var i in document.all) {
		try {document.all[i].style.cursor=c;} catch(e) {}
	}
}

var x0, y0;

function WindowDragHandler() {
	if (event.button!=1){
		window.moveBy(event.x-x0, event.y-y0);
	}
}

document.onmousedown=function () {
	if (event.button!=1){
		x0=event.x; y0=event.y;
		document.onmousemove=WindowDragHandler;
		cursor("move");
	}
};

document.onmouseup=function () {
	document.onmousemove=null;
	cursor("auto");
};

document.mouseout=function () {
	document.onmousemove=null;
	cursor("auto");
};
</script>
</html>
